package com.jackstraw.jack_base.util.entity.mapstruct;

import org.mapstruct.MappingTarget;
import org.mapstruct.Mappings;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Collection;

public abstract class AbstractMapstruct<BO, PO, VO, DTO,
        poMapstruct extends BasicMapstructMapper<BO,PO>,
        voMapstruct extends BasicMapstructMapper<BO,VO>,
        dtoMapstruct extends BasicMapstructMapper<BO,DTO>> {

    /**
     * 创建一个Bo对象，并将入参Bo对象内相同字段赋值给Bo
     *
     * @param bo
     * @return
     */
    @Mappings(value = {})
    public abstract BO boCopy(BO bo);

    /**
     * 类似{@link BasicMapstructMapper#boCopy(Object)} 方法，不过是处理集合
     *
     * @param tos
     * @return
     */
    @Mappings(value = {})
    public abstract Collection<BO> boBoS(Collection<BO> tos);

    /**
     * 将boSource中与boTarget相同字段赋值给boTarget，并返回boTarget
     *
     * @param boSource
     * @param boTarget
     * @return
     */
    @Mappings(value = {})
    public abstract BO boUpdateWithBo(BO boSource, @MappingTarget BO boTarget);


    @Autowired
    protected Class<poMapstruct> poMapstructClass;

    @Autowired
    protected Class<voMapstruct> voMapstructClass;

    @Autowired
    protected Class<dtoMapstruct> dtoMapstructClass;

}

